function SegmentKidney(inputFileName,outputFileName)
if (nargin~=2)
    error('missing input params');
end

close all;

%% load the image
struct = load_untouch_nii(inputFileName);
img = struct.img;


tic;
%% Apply filters to image
% treshold min max values
min=100; % 0 
max=250; % 50
for z=1:size(img,3)
    display(z);        
    layer = double(img(:,:,z));    
    layer = filter_treshold(layer,min,max);    
    layer = filter_erosion(layer,3);   
    layer = filter_dilation(layer,3);              
    layer = filter_bfs(layer);       
    img(:,:,z) = layer;        
end
toc;
%% save back the result image
struct.img = img;
save_untouch_nii(struct,outputFileName);
display('Done [Segment Kidney]');
end